from ultralytics import YOLO

if __name__ == '__main__':
    # Load a model
    model = YOLO('yolov8n.pt')

    # Train the model
    results = model.train(
        data=r'./datasets/dataset_yolo/data.yaml',
        imgsz=1024,
        epochs=100,
        patience=10,
        batch=8,
        workers=8,
        half=True,
        augment=True,
        cache=True,
        rect=True,
        device='0,1',
        lr0=0.001,       # 初始学习率
        lrf=0.01,
        mosaic=1.0,
        mixup=0.5,
        project="runs/train",
        name="deeplesion_v8n",
        exist_ok=True
    )